export default {
	getItem(key) {
		try {
			return JSON.parse(localStorage.getItem(key));
		} catch (error) {
			console.error(`获取localStorage数据失败: ${error}`);
			return null;
		}
	},

	setItem(key, value) {
		try {
			localStorage.setItem(key, JSON.stringify(value));
		} catch (error) {
			console.error(`设置localStorage数据失败: ${error}`);
		}
	},

	removeItem(key) {
		localStorage.removeItem(key);
	},

	clear() {
		localStorage.clear();
	},
};
